package com.example.administrator.testpersionn.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;


import com.example.administrator.testpersionn.R;
import com.example.administrator.out1.bena.OverKeyWorkSpinnerBean;

import java.util.List;

public class OverKeyWorkSpinnerAdapter extends BaseAdapter {
    List<OverKeyWorkSpinnerBean> datas;
    Context context;


    public OverKeyWorkSpinnerAdapter(Context context) {
        this.context = context;

    }


    public void setUserBeans(List<OverKeyWorkSpinnerBean> datas) {
        this.datas = datas;
    }

    @Override
    public int getCount() {
        return datas.size();
    }

    @Override
    public Object getItem(int i) {
        return datas.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        //TODO d单选 todo 各种预览效果
        ViewHolder holder;
        if (view == null) {
            view = LayoutInflater.from(context).inflate(R.layout.item_spinner, viewGroup, false);
            holder = new ViewHolder(view);

            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
        }
        holder.spinnerName.setText(datas.get(i).getName());
        return view;
    }
    class ViewHolder {
        public View rootView;
        public TextView spinnerName;

        public ViewHolder(View rootView) {
            this.rootView = rootView;
            this.spinnerName = (TextView) rootView.findViewById(R.id.spinner_name);
        }

    }
}
